﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Globalization;
using System.Threading;
using System.Configuration;

/// <summary>
/// Summary description for MultipleLangPage
/// </summary>
public class MultipleLangPage : PageBase
{
    protected override void InitializeCulture()
    {
        HttpRequest request = HttpContext.Current.Request;
        string langCode = request["lang"];

        if (string.IsNullOrEmpty(langCode))
        {
            if (Request.UserLanguages != null && Request.UserLanguages.Length > 0)
            {
                langCode = Request.UserLanguages[0];
            }
        }        

        try
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(langCode);
        }
        catch
        {
            string defaultLangCode = ConfigurationManager.AppSettings["DefaultLangCode"];
            if (string.IsNullOrEmpty(defaultLangCode))
            {
                defaultLangCode = "zh-cn";
            }
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(defaultLangCode);
        }
    }
}